home *** CD-ROM | disk | FTP | other *** search
- onClipEvent(enterFrame){
- if(!Paused)
- {
- if(UFO.Active)
- {
- UFO.UnactiveCount = 0;
- if(Key.isDown(40))
- {
- if(UFO.Boxz < MapD)
- {
- UFO.ZSpeed += 2;
- }
- }
- if(Key.isDown(38))
- {
- if(UFO.Boxz > 0)
- {
- UFO.ZSpeed -= 2;
- }
- }
- if(Key.isDown(37))
- {
- if(UFO.Boxx > 0)
- {
- UFO.XSpeed -= 4;
- }
- }
- if(Key.isDown(39))
- {
- if(UFO.Boxx < MapW)
- {
- UFO.XSpeed += 4;
- }
- }
- if(Key.isDown(32))
- {
- if(UFO.ReadyNum > 0)
- {
- UFO.Releasing = true;
- UFO.Active = false;
- }
- else
- {
- RejSound.start();
- }
- }
- }
- else
- {
- UFO.UnactiveCount = UFO.UnactiveCount + 1;
- if(UFO.UnactiveCount > 50)
- {
- ActivateColumn(false);
- UFO.Active = true;
- }
- }
- if(AbductedAtOnce > 1)
- {
- eval("S" + LastAbducted).Bonus.gotoAndPlay(2);
- if(AbductedAtOnce == 2)
- {
- eval("S" + LastAbducted).Bonus.Value.gotoAndStop(1);
- eval("S" + LastAbducted).Bonus.Value.Points = _parent.level * 50;
- }
- if(AbductedAtOnce == 3)
- {
- eval("S" + LastAbducted).Bonus.Value.gotoAndStop(2);
- eval("S" + LastAbducted).Bonus.Value.Points = _parent.level * 150;
- }
- _parent.Score += eval("S" + LastAbducted).Bonus.Value.Points;
- }
- AbductedAtOnce = 0;
- if(_quality != "LOW")
- {
- STC++;
- if(STC == 10)
- {
- time = new Date();
- LastFrameTime = time.getTime();
- }
- if(STC > 10)
- {
- time = new Date();
- TimePerFrame = time.getTime() - LastFrameTime;
- FramesSummary += TimePerFrame;
- LastFrameTime = time.getTime();
- if(STC >= 30)
- {
- AverageTime = FramesSummary / 20;
- if(AverageTime > 70)
- {
- if(_quality == "MEDIUM")
- {
- _quality = "LOW";
- }
- if(_quality == "HIGH")
- {
- _quality = "MEDIUM";
- }
- }
- STC = 0;
- FramesSummary = 0;
- }
- }
- }
- if(UFO.XSpeed != 0)
- {
- UFO.XSpeed -= UFO.XSpeed / Math.abs(UFO.XSpeed) * 2;
- }
- if(UFO.ZSpeed != 0)
- {
- UFO.ZSpeed -= UFO.ZSpeed / Math.abs(UFO.ZSpeed);
- }
- if(UFO.XSpeed > 20)
- {
- UFO.XSpeed = 20;
- }
- if(UFO.XSpeed < -20)
- {
- UFO.XSpeed = -20;
- }
- if(UFO.ZSpeed > 10)
- {
- UFO.ZSpeed = 10;
- }
- if(UFO.ZSpeed < -10)
- {
- UFO.ZSpeed = -10;
- }
- _parent.UFO.gotoAndStop(11 - UFO.ZSpeed);
- _parent.UFO._rotation = UFO.XSpeed;
- MoveBullets();
- _X = _X - UFO.XSpeed;
- _Y = _Y - UFO.ZSpeed;
- UFO.x = 585 - _X * 2;
- UFO.z = 520 - _Y * 2;
- Shadows.High.UFOShadow._x = UFO.x;
- Shadows.High.UFOShadow._y = UFO.z;
- Box = CalculateBox(UFO.x - 17,UFO.z + 7,1,1);
- UFO.Boxx = Box.x;
- UFO.Boxz = Box.z;
- if(Map[UFO.Boxz][UFO.Boxx] == 0 or Map[UFO.Boxz][UFO.Boxx] > 600)
- {
- _parent.Panel.Light6.gotoAndStop(1);
- }
- else
- {
- _parent.Panel.Light6.gotoAndStop(3);
- }
- if(UFO.XSpeed == 0 and UFO.ZSpeed == 0 and UFO.FreeSlots > 0)
- {
- xi = Box.x - 1;
- while(xi <= Box.x + 1)
- {
- zi = Box.z - 2;
- while(zi <= Box.z + 2)
- {
- if(Map[zi][xi] > 0 and Map[zi][xi] < 300 and !eval("S" + Map[zi][xi]).Pacified and UFO.FreeSlots > 0)
- {
- EmpltySlot = -1;
- f = 0;
- while(f < 3)
- {
- if(UFO.AbdSold[f] == 0)
- {
- EmptySlot = f;
- break;
- }
- f++;
- }
- if(EmptySlot != -1)
- {
- eval("S" + Map[zi][xi]).InAbduction = true;
- eval("S" + Map[zi][xi]).Pacified = true;
- FindPhase(eval("S" + Map[zi][xi]));
- eval("S" + Map[zi][xi]).Phase.Body.gotoAndPlay(46);
- UFO.AbdSold[EmptySlot] = Map[zi][xi];
- ActivateColumn(true);
- UpdateSlots();
- LastAbducted = Map[zi][xi];
- AbductedAtOnce++;
- Map[zi][xi] = 0;
- eval("_parent.Panel.Indicator" + EmptySlot).gotoAndPlay(2);
- }
- }
- zi++;
- }
- xi++;
- }
- }
- if(UFO.ReadyNum == 0)
- {
- _parent.Panel.Light4.gotoAndStop(3);
- }
- else
- {
- _parent.Panel.Light4.gotoAndStop(1);
- }
- if(UFO.Releasing and UFO.XSpeed == 0 and UFO.ZSpeed == 0)
- {
- UFO.Releasing = false;
- if(Map[UFO.Boxz][UFO.Boxx] == 0 or Map[UFO.Boxz][UFO.Boxx] > 600)
- {
- ReadySold = -1;
- f = 0;
- while(f < 3)
- {
- if(UFO.AbdSold[f] > 0 and UFO.Ready[f])
- {
- ReadySold = f;
- break;
- }
- f++;
- }
- if(ReadySold != -1)
- {
- UFO.Releasing = false;
- ActivateColumn(true);
- Map[UFO.Boxz][UFO.Boxx] = UFO.AbdSold[ReadySold];
- eval("Shadows.SoldShad" + UFO.AbdSold[ReadySold])._x = eval("S" + UFO.AbdSold[ReadySold])._x = UFO.x - 17;
- eval("Shadows.SoldShad" + UFO.AbdSold[ReadySold])._y = eval("S" + UFO.AbdSold[ReadySold])._y = UFO.z - 7;
- eval("S" + UFO.AbdSold[ReadySold]).swapDepths(UFO.Boxx + MapW * (UFO.Boxz * 4 + 2));
- eval("S" + UFO.AbdSold[ReadySold])._visible = true;
- eval("S" + UFO.AbdSold[ReadySold]).Phase.gotoAndStop(6);
- UFO.AbdSold[ReadySold] = 0;
- UFO.Ready[ReadySold] = false;
- UFO.ReadyNum--;
- eval("_parent.Panel.Indicator" + ReadySold).gotoAndStop(1);
- UpdateSlots();
- }
- else
- {
- UFO.Active = true;
- RejSound.start();
- }
- }
- else
- {
- NoLanding._x = UFO.x - 21;
- NoLanding._y = UFO.z - 7;
- NoLanding.gotoAndPlay(2);
- UFO.Active = true;
- RejSound.start();
- }
- }
- ii = 1;
- while(ii <= TotSold)
- {
- CheckShadow(eval("S" + ii));
- if(!eval("S" + ii).Dead and !eval("S" + ii).Pacified)
- {
- if(Spin(eval("S" + ii)))
- {
- if(eval("S" + ii).Follow)
- {
- FindDirection(eval("S" + ii),S299.x,S299.z);
- }
- else
- {
- eval("S" + ii).Attack = 0;
- MinDis = 150;
- ss = 1;
- while(ss <= TotSold)
- {
- Dis = Math.abs(eval("S" + ii).x - eval("S" + ss).x) + Math.abs(eval("S" + ii).z - eval("S" + ss).z);
- if(ss != ii and Dis < MinDis and eval("S" + ii).Army != eval("S" + ss).Army and !eval("S" + ss).Dead and !eval("S" + ss).Pacified)
- {
- eval("S" + ii).Attack = ss;
- eval("S" + ii).AttackDis = Dis;
- MinDis = Dis;
- }
- ss++;
- }
- if(eval("S" + ii).Attack > 0)
- {
- if(eval("S" + ii).AttackDis > 5 and random(eval("S" + ii).AttackDis) == 0)
- {
- eval("S" + ii).Go = false;
- }
- if(eval("S" + ii).AttackDis > 5 and random(100 - eval("S" + ii).AttackDis) == 0)
- {
- eval("S" + ii).Go = true;
- }
- if(eval("S" + ii).AttackDis <= 5)
- {
- eval("S" + ii).Go = false;
- }
- if(eval("S" + ii).Go and eval("S" + ii).CurPos == eval("S" + ii).DesPos)
- {
- FindDirection(eval("S" + ii),eval("S" + eval("S" + ii).Attack).x,eval("S" + eval("S" + ii).Attack).z);
- }
- else if(eval("S" + ii).Shooting)
- {
- }
- eval("S" + ii).DesPos = CalcDir(eval("S" + ii),eval("S" + eval("S" + ii).Attack));
- eval("S" + ii).Shooting = true;
- }
- else
- {
- eval("S" + ii).Go = true;
- if(eval("S" + ii).Blocked or random(50) == 0)
- {
- if(random(2))
- {
- eval("S" + ii).dir = eval("S" + ii).dir + 1;
- }
- else
- {
- eval("S" + ii).dir--;
- }
- if(eval("S" + ii).dir > 3)
- {
- eval("S" + ii).dir -= 4;
- }
- if(eval("S" + ii).dir < 0)
- {
- eval("S" + ii).dir += 4;
- }
- }
- eval("S" + ii).xGo = eval("S" + ii).XDM[eval("S" + ii).dir];
- eval("S" + ii).zGo = eval("S" + ii).ZDM[eval("S" + ii).dir];
- }
- }
- if(eval("S" + ii).Go)
- {
- eval("S" + ii).DesPos = eval("S" + ii).DirPos[eval("S" + ii).dir];
- }
- if(eval("S" + ii).CurPos == eval("S" + ii).DesPos)
- {
- if(eval("S" + ii).Go)
- {
- eval("S" + ii).Shooting = false;
- eval("S" + ii).Phase.gotoAndStop(eval("S" + ii).dir + 1);
- eval("S" + ii).Phase.Body.play();
- Move(eval("S" + ii));
- }
- else
- {
- eval("S" + ii).Phase.gotoAndStop(5);
- eval("S" + ii).Phase.Body.gotoAndStop(eval("S" + ii).CurPos);
- if(!(Map[eval("S" + ii).z][eval("S" + ii).x] = eval("S" + ii).ind))
- {
- }
- }
- if(eval("S" + ii).Shooting and random(eval("S" + ii).AttackDis + 10) == 0)
- {
- Shoot(eval("S" + ii),eval("S" + eval("S" + ii).Attack));
- eval("S" + ii).Shooting = false;
- }
- }
- else
- {
- eval("S" + ii).Blocked = false;
- }
- }
- }
- ii++;
- }
- }
- }
-